<?php echo $this->title($this->pageTitle) ?>

<table id="product-compare" class="data-table">
<?php
$misc = array(
    'name' => 'Name',
    'description' => 'Description'
);

/* column customization */
$iterator = 0;
echo '<colgroup>';
echo '<col class="col-first col-even" />';
foreach ($this->products as $product) {
    echo '<col class="' . ($iterator++ % 2 ? "col-even" : "col-odd") . '" />';
}
echo '</colgroup>';

/* name */
echo '<thead><tr><th>Product: </th>';
foreach ($this->products as $product) {
    echo '<th>' . 
    '<a href="' . $this->href($this->catalogUrl . '/'. $product['key_word']) .'">' . $product['name'] . '</a>'
    . '</th>';
}
echo '</tr></thead>';

/* image */
echo '<tr><td>&nbsp;</td>';
foreach ($this->products as $product) {
    $imagePath = isset($product['images'][$product['image_listing']]) ?
        $product['images'][$product['image_listing']]['path'] : '';
    $imageTitle = isset($product['images'][$product['image_listing']]) ?
        $product['images'][$product['image_listing']]['title'] : '';
    echo '<td>' . $this->imager('/product' . $imagePath, array(
           'width'  => $this->config()->image->product->widthSmall, 
           'height' => $this->config()->image->product->heightSmall, 
           'alt' => $this->escape($imageTitle), 
           'seo' => $product['image_seo_name']
       )) . '</td>';
}
echo '</tr>';

/* price */
echo '<tr><td><strong>' . $this->translate('catalog')->__('Price')
    .':</strong></td>';
foreach ($this->products as $product) {
    echo '<td>' 
       . $this->price($product['price'])
       . '</td>';
}
echo '</tr>';

foreach ($misc as $key => $label) {
    echo '<tr valign="top"><td><strong>' . $label . '</strong></td>';
    foreach ($this->products as $product) {
        echo '<td>'.$product[$key].'</td>';
    }
    echo '</tr>';
}


/* options(attributes) */
foreach ($this->options as $optionId => $optionName) {
    echo '<tr valign="top"><td><strong>' . $optionName . '</strong></td>';
    foreach ($this->products as $product) {
        if (!isset($product['options'][$optionId])) {
            echo '<td>-</td>';
            continue;
        }
        
        echo '<td>' . implode(', ', $product['options'][$optionId]['values']) . '</td>';
    }
    echo '</tr>';
}

?>

<tr>
    <td>&nbsp;</td>
<?php foreach ($this->products as $prodId => $product) : ?>

    <td>
        <?php if ($product['is_saleable']): ?>
            <?php echo $this->button($this->translate('catalog')->__('Add to cart'), array(
                'class' => 'button btn-add-to-cart',
                'href' => $this->href('checkout/cart/add/productId/' . $prodId, true)
            )) ?>
        <?php else: ?>
            <div class="out-of-stock"><?php echo $this->translate('catalog')->__('Out of stock') ?></div>
        <?php endif ?>
        
        <p class="add-to">
            <a href="<?php echo $this->href('account/wishlist/add/id/' . $prodId, true)?>"
                class="add-to-wishlist"><span><span>
                <?php echo $this->translate('catalog')->__('Add to Wishlist')?></span></span></a>
        </p>
        
        <a href="<?php echo $this->href($this->catalogUrl . '/product-compare/remove/product/' . $prodId) ?>"
           title="Remove from compare list"
            ><?php echo $this->translate('catalog')->__('Remove') ?></a>
    </td>

<?php endforeach; ?>
</tr>
</table>
<script type="text/javascript">
    decorateTable('product-compare');
</script>